import torch

a = torch.rand(2, 3)
b = torch.rand(2, 3)
c = torch.zeros_like(a)
print("a")
print(a)
print("b")
print(b)
print("c")
print(c)


def test_dist():
    print("==== dist a, b ===")
    print("l1范数 torch.dist(a, b, p=1)")
    print(torch.dist(a, b, p=1))
    print()

    print("l2范数 torch.dist(a, b, p=2)")
    print(torch.dist(a, b, p=2))
    print()

    print("l3范数 torch.dist(a, b, p=3)")
    print(torch.dist(a, b, p=3))
    print()

    print("==== dist a, c (和norm对比, c是全0 tensor）===")
    print("l1范数 torch.dist(a, c, p=1)")
    print(torch.dist(a, c, p=1))
    print()

    print("l2范数 torch.dist(a, c, p=2)")
    print(torch.dist(a, c, p=2))
    print()

    print("l3范数 torch.dist(a, c, p=3)")
    print(torch.dist(a, c, p=3))
    print()


def test_norm():
    print("==== norm ===")

    print("l1范数 torch.norm(a， p=1)")
    print(torch.norm(a, p=1))
    print()

    print("l2范数 torch.norm(a,p=2)")
    print(torch.norm(a, p=2))
    print()

    print("l3 范数torch.norm(a, p=3)")
    print(torch.norm(a, p=3))
    print()

    print("l2范数 torch.norm(a)")
    print(torch.norm(a))
    print()


def test_kernal():
    print("==== kernal(核范数) ====")
    print("核范数 torch.norm(a, p='fro')")
    print(torch.norm(a, p="fro"))
    print()


if __name__ == '__main__':
    test_dist()
    test_norm()
    test_kernal()
